package judesart.app.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

@Entity
@NamedQueries( {
        @NamedQuery(name = "Artwork.countByArtistId", query = "select count(o) from Artwork o where o.artistId = :artistId"),
        @NamedQuery(name = "Artwork.countFeaturedByArtistId", query = "select count(o) from Artwork o where o.artistId = :artistId and o.featured = true"),
        @NamedQuery(name = "Artwork.findByArtistId", query = "select o from Artwork o where o.artistId = :artistId"),
        @NamedQuery(name = "Artwork.findIdsByArtistId", query = "select o.id from Artwork o where o.artistId = :artistId"),
        @NamedQuery(name = "Artwork.findFeaturedIdsByArtistId", query = "select o.id from Artwork o where o.artistId = :artistId and o.featured = true")})
public class Artwork implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @Basic
    private Long artistId;
    @Basic
    @NotNull
    private String title;
    @Basic
    private String description;
    @Basic
    @NotNull
    private String dimensions;
    @Basic
    @Min(value = 1966)
    private long year;
    @Basic
    @Enumerated(EnumType.STRING)
    @NotNull
    private ArtworkType type;
    @Basic
    @NotNull
    private String technic;
    @Basic
    private List<String> tags;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "artwork")
    private List<ArtworkPhoto> photos;
    @Basic
    private Date createdAt;
    @Basic
    private Boolean forSale;
    @Basic
    private Double price;
    @Basic
    private Boolean featured;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getArtistId() {
        return artistId;
    }

    public void setArtistId(Long artistId) {
        this.artistId = artistId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDimensions() {
        return dimensions;
    }

    public void setDimensions(String dimensions) {
        this.dimensions = dimensions;
    }

    public long getYear() {
        return year;
    }

    public void setYear(long year) {
        this.year = year;
    }

    public ArtworkType getType() {
        return type;
    }

    public void setType(ArtworkType type) {
        this.type = type;
    }

    public String getTechnic() {
        return technic;
    }

    public void setTechnic(String technic) {
        this.technic = technic;
    }

    public List<String> getTags() {
        return tags;
    }

    public void setTags(List<String> tags) {
        this.tags = tags;
    }

    public List<ArtworkPhoto> getPhotos() {
        return photos;
    }

    public void setPhotos(List<ArtworkPhoto> photos) {
        this.photos = photos;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    public Boolean getForSale() {
        return forSale;
    }

    public void setForSale(Boolean forSale) {
        this.forSale = forSale;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

	public Boolean getFeatured() {
		return featured;
	}

	public void setFeatured(Boolean featured) {
		this.featured = featured;
	}
}
